/**
 * @file TeacherHome.vue
 * @description 教师端首页组件
 * @created 2024-03-20
 */

<template>
  <div class="teacher-layout">
    <!-- 侧边栏 -->
    <div class="sidebar">
      <div class="logo">
        <h1>华侨大学</h1>
        <p>教师管理系统</p>
      </div>
      <nav class="nav-menu">
        <router-link to="/manage" class="nav-item">
          <span class="icon">📊</span>
          <span>教学资源管理</span>
        </router-link>
        <router-link to="/chat/WMO8HYUTaAvMvfX2" class="nav-item">
          <span class="icon">📚</span>
          <span>教案智能生成</span>
        </router-link>
        <router-link to="/chat/ANOTHER_BOT_ID" class="nav-item">
          <span class="icon">👨‍🎓</span>
          <span>讲义生成</span>
        </router-link>
        <router-link to="/Analysis" class="nav-item">
          <span class="icon">📑</span>
          <span>学生学情分析</span>
        </router-link>
        <router-link to="/homework" class="nav-item">
          <span class="icon">📈</span>
          <span>作业管理</span>
        </router-link>
        <router-link to="/knowledge-dataset" class="nav-item">
          <span class="icon">🗂️</span>
          <span>知识库管理</span>
        </router-link>
      </nav>
    </div>

    <!-- 主内容区 -->
    <div class="main-content">
      <!-- 顶部栏 -->
      <div class="header">
        <div class="breadcrumb">
          首页 / {{ currentPage }}
        </div>
        <div class="user-info">
          <span class="welcome">欢迎，{{ teacherName }}</span>
          <el-dropdown>
            <span class="el-dropdown-link">
              <el-avatar :size="32" :src="avatarUrl"></el-avatar>
            </span>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item>个人信息</el-dropdown-item>
                <el-dropdown-item>修改密码</el-dropdown-item>
                <el-dropdown-item @click="handleLogout">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </div>

      <!-- 路由视图 -->
      <div class="content">
        <router-view></router-view>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { useUserStore } from '@/stores/modules/user'

const router = useRouter()
const route = useRoute()
const userStore = useUserStore()

// 模拟数据
const teacherName = ref('王靖')
const avatarUrl = ref('/public/烟绯.jpg')

// 计算当前页面名称
const currentPage = computed(() => {
  return route.meta.title || '首页'
})

// 退出登录
const handleLogout = () => {
  userStore.clearUserInfo()
  router.push('/login')
}
</script>

<style scoped>
.teacher-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: #2c2c54;
  color: white;
  padding: 20px 0;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
}

.logo {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo h1 {
  font-size: 24px;
  margin-bottom: 8px;
}

.logo p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

.nav-menu {
  padding: 20px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 24px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: all 0.3s;
}

.nav-item:hover,
.nav-item.router-link-active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-item .icon {
  margin-right: 12px;
  font-size: 20px;
}

.main-content {
  flex: 1;
  background: #f6f8fa;
}

.header {
  background: white;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.breadcrumb {
  color: #666;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.welcome {
  color: #333;
}

.content {
  padding: 24px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .sidebar {
    width: 80px;
  }

  .nav-item span:not(.icon) {
    display: none;
  }

  .logo h1, .logo p {
    display: none;
  }
}
</style> 